package mac.runtimeChecker.medlParser;

import mac.types.parserTypes.*;

public class ASTCondition extends SimpleNode {
  static final int AND = 0;	// Boolean AND
  static final int OR = 1;	// Boolean OR
  static final int XOR = 2;	// Bitwise XOR
  static final int NOT = 3;
  static final int INM = 4;
  static final int EQ = 5;
  static final int NEQ = 6;
  static final int LT = 7;
  static final int LE = 8;
  static final int GT = 9;
  static final int GE = 10;
  static final int INSTANCEOF = 11;
  static final int PARENTHESIS = 12;
  static final int CONSTANT = 13;
  static final int ASSIGNMENT = 14;
  static final int PAIR = 15;

  protected int op;
  protected String name;
  protected Object value;
  protected Object oldValue;

  ASTCondition(int id) {
    super(id);
  }

  public int getOp() {
    return op;
  }
  public String getName() {
    return name;
  }
  public Object getValue() {
    return value;
  }
  public Object getOldValue() { 
    return oldValue;
  }
  public void setOp(int o) {
    op =o;
  }
  public void setName(String n) {
    name = n;
  }
  public void setValue(Object v) {
    value = v;
  }
  public void setOldValue(boolean v) {
    oldValue = new Boolean(v);
  }

  public String toString() {
    String s= null;
    String s2= null;
    Object realValue = null;
    SymtabEntry se = null;

    switch (op) {
      case AND: s =  "Condition: and";break; 
      case OR: s =  "Condition: or";break; 
      case XOR: s =  "Condition: xor";break; 
      case NOT: s =  "Condition: not";break; 
      case INM: s =  "Condition: in method";break; 
      case EQ: s =  "Condition: equal";break; 
      case NEQ: s =  "Condition: not equal";break; 
      case LT: s =  "Condition: less than";break; 
      case LE: s =  "Condition: less than or equal";break; 
      case GT: s =  "Condition: greater than";break; 
      case GE: s =  "Condition: greater than or equal";break; 
      case INSTANCEOF: s =  "Condition: instance of";break; 
      case PARENTHESIS: s =  "Condition: parenthesis";break; 
      case CONSTANT: s =  "Condition: constant";break; 
      case ASSIGNMENT: s =  "Condition: assignment";break; 
      case PAIR: s = "Condition: pair"; break;
      default: s =  "Condition: error";break; 
    }
    return s;
  /*    if(value instanceof SymtabEntry) {
	  se = (SymtabEntry)value;
	  if( ((String)(se.getType())).equals("_macType")) {
	      realValue = ((Node)(se.getValue())).getValue(); 
	  } else {
	      realValue = se.getValue();
	  }
      } else {
	  realValue = value;
      }

      return s + "(name:"+ name + ",value:" 
	    + realValue + ",mark:" + mark +")" ;
*/
  }
}
